package com.yanqu.road.server.manger.player;

import com.yanqu.road.dao.impl.player.WechatRankBlackUserDaoImpl;
import com.yanqu.road.entity.player.WechatRankBlackUserData;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manger.ChannelConfigMgr;
import com.yanqu.road.server.manger.ServerListMgr;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 微信排行黑名单玩家MGR
 */
public class WechatRankBlackUserMgr extends TempMgr {

    /**
     * 微信排行黑名单玩家
     */
    private static Map<String, WechatRankBlackUserData> wechatRankBlackUserMap = new ConcurrentHashMap<>();

    @Override
    public boolean init() throws Exception {
        return reloadData();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        //渠道
        int channelId = ServerListMgr.getChannelId(GameServer.getInstance().getServerId());
        WechatRankBlackUserDaoImpl dao = new WechatRankBlackUserDaoImpl();
        wechatRankBlackUserMap = dao.getWechatRankBlackUserData(channelId);
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    /**
     * 判断是否是黑名单玩家
     * @param openId
     * @return
     */
    public static boolean isWechatRankBlackUser(String openId) {
        return wechatRankBlackUserMap.containsKey(openId);
    }
}
